package lambda;




import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Supplier;

public class SupplierTest {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<Integer>();

        System.out.println(getMax(() -> {
            arrayList.add(3);
            arrayList.add(8);
            Collections.sort(arrayList);
            return arrayList.get(arrayList.size()-1);
        }));
    }


    //返回一个最大的int值
    private static int getMax(Supplier<Integer> supplier) {
        return supplier.get();
    }
}
